import requests


def get_image_bytes(url):
    """
    获取字节和编码
    :param url: 下载链接
    :return bytes
    """
    return requests.get(url).content


def write_file(bs, path):
    with open(path, 'wb') as f:
        f.write(bs)


if __name__ == '__main__':
    url = 'https://bing.ioliu.cn/photo/FreshSalt_ZH-CN12818759319?force=download'
    import time
    write_file(get_image_bytes(url), f'./{time.time()}.png')
